home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / MiniGames / BTW / BTWBall.as < prev    next >
Text File  |  2013-04-24  |  3KB  |  92 lines

  1. class MiniGames.BTW.BTWBall extends State
  2. {
  3.    static var sSTATE_MOVE = "Move";
  4.    static var sSTATE_EXPLODE = "Explode";
  5.    static var sSTATE_DESTROYED = "Destroyed";
  6.    static var sLINKAGE_BALL = "SB_ASP_IceBall";
  7.    var nSPEED = 2;
  8.    static var nCOUNTER = 0;
  9.    static var nNB_SPLASH_SOUNDS = 5;
  10.    static var nSPLASH_VOLUME = 100;
  11.    function BTWBall(_mcParent, _oWallTarget, _nX, _nY)
  12.    {
  13.       super(_mcParent.attachMovie(MiniGames.BTW.BTWBall.sLINKAGE_BALL,"mcBall" + ++MiniGames.BTW.BTWBall.nCOUNTER,_mcParent.getNextHighestDepth()));
  14.       this.mcRef._x = _nX;
  15.       this.mcRef._y = _nY;
  16.       this.isExplodingOnce = false;
  17.       this.setState(MiniGames.BTW.BTWBall.sSTATE_MOVE);
  18.       this.oWallTarget = _oWallTarget;
  19.       var _loc7_ = this.mcRef._x - this.oWallTarget.mcRef._x;
  20.       var _loc8_ = this.mcRef._y - this.oWallTarget.mcRef._y;
  21.       var _loc9_ = _loc8_ / _loc7_;
  22.       this.nSPEED = 5 / 30 * _loc7_;
  23.       this.nX = this.nSPEED;
  24.       this.nY = _loc9_ * this.nSPEED;
  25.       if(_loc7_ > _loc8_)
  26.       {
  27.          _loc9_ = _loc7_ / _loc8_;
  28.          this.nSPEED = 5 / 30 * _loc8_;
  29.          this.nX = _loc9_ * this.nSPEED;
  30.          this.nY = this.nSPEED;
  31.       }
  32.       this.setState(MiniGames.BTW.BTWBall.sSTATE_MOVE);
  33.    }
  34.    function cleanUp()
  35.    {
  36.       this.mcRef.removeMovieClip();
  37.    }
  38.    function isDestroyed()
  39.    {
  40.       var _loc2_ = false;
  41.       if(this.sState == MiniGames.BTW.BTWBall.sSTATE_DESTROYED)
  42.       {
  43.          _loc2_ = true;
  44.       }
  45.       return _loc2_;
  46.    }
  47.    function isExploding()
  48.    {
  49.       var _loc2_ = false;
  50.       if(this.sState == MiniGames.BTW.BTWBall.sSTATE_EXPLODE && this.isExplodingOnce == false)
  51.       {
  52.          _loc2_ = true;
  53.          this.isExplodingOnce = true;
  54.       }
  55.       return _loc2_;
  56.    }
  57.    function get Target()
  58.    {
  59.       return this.oWallTarget;
  60.    }
  61.    function Move()
  62.    {
  63.       if(!Controller.getRef().isPaused())
  64.       {
  65.          this.mcRef._x -= this.nX;
  66.          this.mcRef._y -= this.nY;
  67.          if(this.mcRef._x <= this.oWallTarget.mcRef._x && this.mcRef._y <= this.oWallTarget.mcRef._y)
  68.          {
  69.             if(!this.oWallTarget.isDestroyed())
  70.             {
  71.                this.setState(MiniGames.BTW.BTWBall.sSTATE_EXPLODE);
  72.                Controller.getRef().getSounds().playRandomSound(MiniGames.BTW.BTWBall.nNB_SPLASH_SOUNDS,"IceBall_Splashed",MiniGames.BTW.BTWBall.nSPLASH_VOLUME);
  73.             }
  74.             else
  75.             {
  76.                this.setState(MiniGames.BTW.BTWBall.sSTATE_DESTROYED);
  77.             }
  78.          }
  79.       }
  80.    }
  81.    function Explode()
  82.    {
  83.       if(this.stateFinished())
  84.       {
  85.          this.setState(MiniGames.BTW.BTWBall.sSTATE_DESTROYED);
  86.       }
  87.    }
  88.    function Destroyed()
  89.    {
  90.    }
  91. }
  92.